package semana3.strings.ejercicios.ej16_numMayYMinusc;

import java.util.Scanner;

public class NumeroMayuscYMinusc {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		System.out.println("Introduce una frase: ");
		String frase = scan.nextLine();

		int numMayusculas = contarMayusculas(frase);
		int numMinusculas = contarMinusculas(frase);
		System.out.println("Esta frase tiene " + numMayusculas + " mayusculas");
		System.out.println("Esta frase tiene " + numMinusculas + " minusculas");
	}

	private static int contarMayusculas(String frase) {
		int contador = 0;

		for (int i = 0; i < frase.length(); i++) {
			if (esMayuscula(frase.charAt(i))) {
				contador++;
			}
		}

		return contador;
	}

	private static boolean esMayuscula(char c) {
		boolean mayuscula = false;

		if (c >= 65 && c <= 90) {
			mayuscula = true;
		}

		return mayuscula;
	}

	private static boolean esMinuscula(char c) {
		boolean minuscula = false;

		if (c >= 97 && c <= 123) {
			minuscula = true;
		}

		return minuscula;
	}

	private static int contarMinusculas(String frase) {
		int contador = 0;

		for (int i = 0; i < frase.length(); i++) {
			if (esMinuscula(frase.charAt(i))) {
				contador++;
			}
		}

		return contador;
	}
}
